package com.xyt.imei.core.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;

import com.luminary.common.framework.core.auth.RoleProvider;
import com.luminary.common.framework.core.auth.TokenValidator;
import com.luminary.common.framework.core.properties.MetaProperties;
import com.xyt.imei.core.auth.HttpHeaderTokenValidator;

@Configuration
public class AuthConfiguration {

	@Autowired
	private RedisTemplate<String, String> redisTemplate;
	
	@Autowired
	private MetaProperties metaProperties;
	
	@Autowired
	private RoleProvider<Integer> roleProvider;
	
	@Bean
	public TokenValidator tokenValidator() {
		return new HttpHeaderTokenValidator(redisTemplate, metaProperties.getRootStaticPagePath(), metaProperties.getTokenHeaderParam(), roleProvider);
	}
	
}
